home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / turbovis / ned103.zip / NEWEDIT.DOC < prev    next >
Text File  |  1992-08-28  |  45KB  |  1,125 lines

  1. INTRODUCTION
  2. ------------
  3.  
  4. I originally started this project to add a wordwrap feature to
  5. the Turbo Vision EDITORS unit.  To make matters worse, I'm new
  6. to Pascal, and trying to learn the language, Turbo
  7. Vision, and event driven programming was just a bit of a
  8. hurdle.  So I asked for help, LOTS of help, and the next thing
  9. I knew I was working with people I've never met trying to
  10. create a full-blown IDE compatible wordprocessor, with the
  11. wordwrap!
  12.  
  13. Well, it got done, minus the IDE select text features such as
  14. read/write/indent blocks, etc.  If nothing else, it was one way
  15. of learning three things at once.  We all had a lot of fun,
  16. probably at my expense <grin>.
  17.  
  18. NEWEDIT.PAS is a complete replacement for the original EDITORS
  19. unit.  It's major contribution is the implementation of a
  20. wordwrap feature.  It also has several other features, which
  21. will be outlined below.
  22.  
  23. If you decide to use the NEWEDIT unit with your applications,
  24. be sure you change your use clause from "uses Editors" to "uses
  25. NewEdit" in all code modules that require the editor.  Those
  26. modules included in the NED103.ZIP file already do this.
  27.  
  28. You should NOT overwrite your original EDITORS.PAS file!  Keep
  29. it for reference should you decide to dig into the work I have
  30. done and add your own features.  Comparison is a learning tool!
  31.  
  32. The rest of this document deals with the modifications I have
  33. made, discussing how they work, and whatever quirks you should
  34. be familiar with.  A command summary is also provided of all
  35. the NEWEDIT options.  Last of all, a brief discussion is given
  36. that explains how to implement your own customized key
  37. commands.
  38.  
  39. Please note that this document is NOT written for users.  It is
  40. written for you, the programmer.  A lot of the information
  41. contained herein would severely confuse your users due to its
  42. technical nature.  Don't make life harder on them by cutting
  43. and pasting the current text to make a quick users guide.  Take
  44. the time and effort to write your own, and make it as simple as
  45. possible.
  46.  
  47.  
  48.  
  49. HOW TO USE IT
  50. -------------
  51.  
  52. I figured I'd put this right up front so you can jump right into it.
  53. You can use the program either as is, or you can yank out NEWEDIT and
  54. simply patch it into your application.  I'll discuss both methods.
  55.  
  56.  
  57.  
  58. Using NEDEMO
  59. ------------
  60.  
  61. Your best bet is to create a directory and dump all the NED103.ZIP files
  62. into it.  Baring that, put the files wherever you want.
  63.  
  64. Next, ensure that all the units called in NEDEMO.PAS are available for
  65. compilation.  Now, compile the NEDEMO.PAS source.  All the other units
  66. will compile.  If you get an error message stating that a unit can't be
  67. compiled, fix your Options|Directories so the path to the unit is
  68. correct.  Or, take the unit TPU or PAS file and put it in your
  69. compilation directory.
  70.  
  71.  
  72.  
  73. Plug Into Your Application
  74. --------------------------
  75.  
  76. The NEWEDIT unit is plug-in compatible with the standard EDITORS unit.
  77. If you're not interested in the NEDEMO program, but want to use the
  78. NEWEDIT unit as is, you can easily patch it into your application.
  79.  
  80. You will need the EDITPKG.PAS and NEWEDIT.PAS programs.  NEWEDIT.PAS is
  81. the actual editor.  EDITPKG.PAS contains all the dialogs and calls to
  82. the clipboard and editor.
  83.  
  84.  
  85. 1)  In your main application INIT constructor, insert this line BEFORE
  86.     you use "TApplication.Init":
  87.  
  88.         EditPkg.Initialize_The_Editor;
  89.  
  90.     Then load any previous desktop and disable any editor commands you
  91.     don't want the user to have immediate access to.
  92.  
  93.     Last of all, initialize the clipboard with this code:
  94.  
  95.         EditPkg.Initialize_The_Clipboard;
  96.  
  97.     Look at the T_EditDemo.Init code in NEDEMO.PAS if you have
  98.     questions.
  99.  
  100. 2)  In your main application HandleEvent code, insert this line for
  101.     opening new files:
  102.  
  103.         cmNew          : EditPkg.Open_Editor ('', True);
  104.  
  105. 3)  In your main application HandleEvent code, insert this line for
  106.     opening existing disk files:
  107.  
  108.         cmOpen         : EditPkg.Run_The_Editor;
  109.  
  110. 4)  If you write the desktop to disk, for any reason, be sure you
  111.     deallocate and reallocate the clipboard.  Failure to do so will
  112.     cause your desktop file to start growing and growing!  Insert this
  113.     code around your save desktop code:
  114.  
  115.  
  116.       EditPkg.Deallocate_The_Clipboard;
  117.  
  118.       {Your code goes here!}
  119.  
  120.       EditPkg.Initialize_The_Clipboard;
  121.  
  122.  
  123.     If you have any questions on this, look in the NEDEMO.PAS
  124.     T_EditDemo.Save_Desktop function for how it should be done.
  125.  
  126. 5)  In your application's DONE destructor, be sure you deallocate the
  127.     editor buffer AFTER "TApplication.Done":
  128.  
  129.       TApplication.Done;
  130.       EditPkg.Deallocate_The_Editor;
  131.  
  132. 6)  Check all units to ensure that "uses EDITORS" is changed to "uses
  133.     NEWEDIT".
  134.  
  135. 7)  If you want to use my help system, the EDITHELP.TXT file will
  136.     probably have to be revised to suit your hc???? constant naming
  137.     convention.   That, or you'll have to write your own.
  138.  
  139.  
  140. It's not as difficult as it sounds.  I've done it with a minimum of
  141. fuss, and several of the beta testers have done the same thing.
  142.  
  143.  
  144.  
  145. CREATING HELP
  146. -------------
  147.  
  148. The file EDITHELP.TXT contains the source for the context sensitive help
  149. system.  You must compile it with the TVHC.EXE program to make it
  150. functional.  Included with NED103 is a MAKEHELP.BAT file.  Simply type
  151. MAKEHELP to generate a usable help file.  Ensure that TVHC is in your
  152. directory or path.
  153.  
  154. I've done things a bit different than normal here, so some explanation
  155. might be in order.
  156.  
  157. All cm???? and hc???? constants are in the CMDFILE.PAS file. Seeing as
  158. I've mixed these constants, I didn't want CMDFILE.PAS to be overwritten
  159. by the TVHC program.  What I do in the batch file is to let TVHC
  160. generate an EDITHELP.PAS, EDITHELP.TPU, and EDITHELP.HLP file.  I then
  161. rename the EDITHELP.HLP file to NEDEMO.HLP and erase the EDITHELP.TPU
  162. file.  I keep the EDITHELP.PAS file as a handy alphabetical reference.
  163.  
  164. So, the short of it is that NEDEMO requires that the CMDFILE unit be
  165. available and that the help file be named NEDEMO.HLP.
  166.  
  167.  
  168.  
  169. CODING STYLE
  170. ------------
  171.  
  172. Every one has their way of doing things, and I'm as guilty as the next
  173. person.  The only reason I bring it up is that coding style may look
  174. very foreign to those who do it Borland's way.  This is not a
  175. justification, just an explanation!
  176.  
  177. I code the way I do so that I can quickly convert code between C,
  178. PASCAL, and Ada.
  179.  
  180. I don't put all of my if/elses on one line.  I like to see which
  181. condition is met when I'm debugging.
  182.  
  183. I use lots of white space so things don't look as bad as they really
  184. are<grin>.
  185.  
  186. I use 43/50 column mode and print in compressed mode, therefore my code
  187. does tend to go beyond the right margin.
  188.  
  189. Last of all, and this is probably important to some of you, I use fully
  190. qualified variable and procedure/function names.  I HATE having to
  191. figure out where a variable or procedure/function is.  Where I work,
  192. people are summarily shot for failing to do so!
  193.  
  194.  
  195.  
  196. WHEN IS A BUG NOT A BUG?
  197. ------------------------
  198.  
  199. When it's a feature, of course!  I've seen several so-called bug
  200. reports describing what the authors consider to be bugs in the
  201. EDITORS unit, when in fact they are reporting features.
  202. Granted, there are some bugs there, and the service these
  203. authors provide by reporting them is invaluable.
  204.  
  205. To set the record straight, the following two items are NOT
  206. bugs!
  207.  
  208. 1)  Pressing ^T will in some instances delete more than just the
  209.     word you want deleted.
  210.  
  211.     Sorry, this is NOT a bug!  The Editors unit defines a
  212.     particular character set.  Any character not in that
  213.     character set is a "non-character".  ^T works like this:
  214.  
  215.     a)  Delete from the cursor position all characters to the
  216.         first character not defined in our character set.  That
  217.         takes care of the current word.
  218.  
  219.     b)  Now we need to delete all characters NOT in the
  220.         character set to the next character that IS in the
  221.         character set.  That deletes the "blank space" between
  222.         words.
  223.  
  224.     Step B